package com.sdutcm.xuake.xuanke_demo.controller;

import com.sdutcm.xuake.xuanke_demo.bean.Course;
import com.sdutcm.xuake.xuanke_demo.service.CourseService;
import com.sdutcm.xuake.xuanke_demo.service.XuanKeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 小浩
 * @date 2018-09-20 01:12
 * @package com.sdutcm.xuake.xuanke_demo.controller
 * @description
 */
@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    XuanKeService xuanKeService;
    @Autowired
    CourseService courseService;
    @RequestMapping("/xuanke")
    public boolean  xuanKe(int xuehao,String kechengming){
        try {
            return xuanKeService.xuanKe(xuehao,kechengming);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    @RequestMapping("/tuike")
    public boolean  tuiKe(int xuehao,String kechengming){

        return xuanKeService.tuiKe(xuehao,kechengming);
    }

    @RequestMapping("/getAll")
    public List<Course> getAll(){
        return courseService.findAllCourse();
    }

    @RequestMapping("/get_by_name")
    public Course getByName(String name){
        return courseService.findCourseByName(name);
    }
}
